var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res) {
	res.send(JSON.stringify(req.query))
});

router.post('/', function(req, res) {
	var msg = "";
	if (req.body.username) {
		if (req.body.userpass == req.body.username + "1") {
			req.session.username = req.sessionID;
			//req.session.sid = req.sessionID;
		} else {
			msg = "password error";
		}
	} else {
		msg = "param error"+JSON.stringify(req.body)
	}
	if (msg == "") {
		res.redirect('index1.html');
	} else {
		res.render('index', {
			msg: msg
		});
	}
});


module.exports = router;